  <?php
session_start(); 
include('connection.php');
$tbl_name="adminlogin";

$username=$_POST['username']; 
$password=$_POST['password'];
$remember=$_POST['remember'];
if(isset($remember))
{
setcookie("rememberpassword",$password,time()+3600*24);
setcookie("rememberusername",$username,time()+3600*24);
}
if(isset($_COOKIE['rememberpassword']) && isset($_COOKIE['rememberusername']) && !isset($remember) )
{
	
	setcookie('rememberpassword',"",time()-3600*24);
    setcookie('rememberusername', "", time()-3600*24);
	
}

$sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'";
$result=mysql_query($sql);

$row  = mysql_fetch_array($result);
if($row)
 {
	
$_SESSION['username']= $username;
$_SESSION['password']= $password;
header("location:index.php");
}

else
 {
header("location:index.php?error=1");
 }

?>